<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%@ taglib uri="/WEB-INF/tlds/att.tld" prefix="att"%>

<html>

<head>
<meta name="decorator" content="moduleEdit" />
<style type="text/css">
h4{ border-bottom:1px dotted #ccc; padding-bottom:10px; margin:30px 0 15px; color:#b12028; font-size: 12px;}
.span-required{color: red;}
</style>
<script type="text/javascript">
	$(function() {
		//找到联系人目前最大行
		max_tr_contact = $("#hidden_mgtScope").closest("table").find("tr").length - 2;

	})

	//添加隐藏域
	function add_hidden(tId, tList) {
		var tr = $(tId).clone();
		var table = $(tId).closest("table");
		//替换所有的hidden，方便spring的form绑定
		var inputs = tr.find("input");
		if (tId == "#hidden_mgtScope") {
			max_tr_contact++;
		}
		inputs.each(function() {
			if (tId == "#hidden_mgtScope") {
				this.id = tList + max_tr_contact + this.id;
				this.name = tList + "[" + max_tr_contact + "]" + this.name;
			}

		});
		//为所有的select绑定
		var selects = tr.find("select");
		selects.each(function() {
			this.id = tList + max_tr_contact + this.id;
			this.name = tList + "[" + max_tr_contact + "]" + this.name;

		});
		tr.show();
		table.append(tr);
	}
	function delete_tr(t, dList) {
		var tr = $(t).closest("tr");
		var id = tr.find("input :first").val();
		if (id != 0) {
			var val = $(dList).val();
			if (val == "") {
				$(dList).val(id);
			} else {
				$(dList).val(val + "," + id);
			}
		}
		tr.remove();

	}

	$(document).ready(function() {
		$(".o-a-form-date").datetimepicker({
			language : 'zh-CN',
			autoclose : true,
			minView : 2,
			todayBtn : 1,
			pickerPosition : "bottom-left"
		});
	})
</script>

</head>
<body>


<div class="Report_f">
           <div class="Report_f_1">
                <div class="Report_f_title_1">供应商准入</div>
                <ul class="nav nav-tabs Report_f_title_2">
                    <li><a href="#label_1" data-toggle="tab">经营或代理品牌信息</a></li>
                  </ul>
			<!-- Tab panes -->
			<div class="tab-content Report_f_title_3">
                  <div class="tab-pane active" id="label_1">
                    <div class="Report_f_title_4">
					<form:form id="backupBrandForm" name="backupBrandForm"  modelAttribute="backupBrand" action="${contextPath}/biz/brand/brandcust/save" method="post" class="form-inline" role="form">
						<form:hidden path="id" />
						<form:hidden path="supplierAccountId" />
						<tags:message content="${message}" />
						<div class="f_2">
							<div class="form-group col-sm-6">
								<label for="brandCname" class="col-sm-3 control-label f_4">品牌中文名:</label>
								<div class="col-sm-9 f_6">
									<form:input id="brandCname" path="brandCname" maxlength="200" class="f_5 required" />
								</div>
							</div>
							<div class="form-group col-sm-6">
								<label for="brandEname" class="col-sm-3 control-label f_4">品牌英文名:</label>
								<div class="col-sm-9 f_6">
									<form:input id="brandEname" path="brandEname" maxlength="200" class="f_5" />
								</div>
							</div>
					   </div>
					   <div class="f_2">
							<div class="form-group col-sm-6">
								<label for="investmentCate" class="col-sm-3 control-label f_4">招商分类:</label>
								<div class="col-sm-9 f_6">
									<form:input id="investmentCate" path="investmentCate" htmlEscape="false" rows="4" class="f_5 required" />
								</div>
							</div>
							<div class="form-group col-sm-6">
								<label for="managementShops" class="col-sm-3 control-label f_4">经营门店总数:</label>
								<div class="col-sm-9 f_6">
									<form:input id="managementShops" path="managementShops" htmlEscape="false" rows="4" class="f_5 required" />
								</div>
							</div>
					   </div>
					   <div class="f_2">
							<div class="form-group col-sm-6">
								<label for="sales" class="col-sm-3 control-label f_4">经营业绩总计:</label>
								<div class="col-sm-9 f_6">
									<form:input id="sales" path="sales" htmlEscape="false" rows="4" class="f_5 required" />
								</div>
							</div>
							<div class="form-group col-sm-6">
								<label for="isCoopPlan" class="col-sm-3 control-label f_4">计划与茂业合作:</label>
								<div class="col-sm-9 f_6">
									<form:radiobutton path="isCoopPlan" id="isCoopPlan" value="0" label="否" />
									<form:radiobutton path="isCoopPlan" id="isCoopPlan" value="1" label="是" />
								</div>
							</div>
					   </div>
					   <div class="f_3">
		                      <div class="form-group col-xs-12">
								<label for="coopNeed" class="col-lb-1 control-label f_10">合作需求:</label>
								<div class="col-sm-10 col-lb-2 f_6">
									<form:textarea id="coopNeed" path="coopNeed" class="form-control f_11"  maxlength="300"/>
								</div>
							 </div>
						</div>
						<h4>供应商覆盖范围
						</h4>
					<table class="table table-striped table-hover o-l-table table-bordered" id="table1">
						<thead class="t_1">
						<tr>
							<th>商场业态</th>
							<th>区域编码</th>
							<th>省份编码</th>
							<th>城市编码</th>
							<th>商场编码</th>
							<th>楼层</th>
							<th>合作方式</th>
							<th>经营面积</th>
							<th>专柜位置</th>
							<th>销售情况</th>
							<th>
								<button onclick="add_hidden('#hidden_mgtScope','mgtScopeList');"
								type="button" class="btn btn-warning btn_1 pull-right">添&nbsp;加</button>
							</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${supplier.supplierContactsList}"
							varStatus="var">
							<tr>
								<form:hidden path="mgtScopeList[${var.index}].id" maxlength="20"
									class="form-control required" />
								<form:hidden path="mgtScopeList[${var.index}].backupBrandId"/>

								<td class="col-sm-2"><form:input
										id="mgtScopeList[${var.index}].marketType"
										path="supplierContactsList[${var.index}].marketType"
										maxlength="200" class="f_5" /></td>
								<td><form:input id="mgtScopeList[${var.index}].regionNo"
										path="mgtScopeList[${var.index}].regionNo" maxlength="200"
										class="form-provinceNo " /></td>
								<td><form:input id="mgtScopeList[${var.index}].provinceNo"
										path="mgtScopeList[${var.index}].provinceNo" maxlength="200"
										class="form-provinceNo " /></td>
								<td><form:input id="mgtScopeList[${var.index}].cityNo"
										path="mgtScopeList[${var.index}].cityNo" maxlength="200"
										class="f_5" /></td>
								<td><form:input id="mgtScopeList[${var.index}].companyNo"
										path="mgtScopeList[${var.index}].companyNo" maxlength="200"
										class="f_5" /></td>
								<td><form:input id="mgtScopeList[${var.index}].floor"
										path="mgtScopeList[${var.index}].floor" maxlength="200"
										class="f_5" /></td>
								<td><form:input id="mgtScopeList[${var.index}].cooperateMode"
										path="mgtScopeList[${var.index}].cooperateMode" maxlength="200"
										class="f_5" /></td>
								<td><form:input id="mgtScopeList[${var.index}].operateArea"
										path="mgtScopeList[${var.index}].operateArea" maxlength="200"
										class="f_5" /></td>
								<td><form:input id="mgtScopeList[${var.index}].specialPosition"
										path="mgtScopeList[${var.index}].specialPosition" maxlength="200"
										class="f_5" /></td>
								<td><form:input id="mgtScopeList[${var.index}].sellCondition"
										path="mgtScopeList[${var.index}].sellCondition" maxlength="200"
										class="f_5" /></td>
								<td><input type="button"
									onclick="delete_tr(this,'#delScopeId')" value="删除"
									class="btn btn-default btn-sm"></td>
							</tr>
						</c:forEach>
						<!-- 隐藏行，用于新增明细start -->
						<tr style="display: none" id="hidden_mgtScope">
							<input type="hidden" maxlength="20" value="0"
								class="form-control required" name=".id" id=".id">
							<input type="hidden" maxlength="20" value="${backupBrand.id }"
								class="form-control required" name=".backupBrandId"
								id=".backupBrandId">
							<td style="width: 100px;"><select id=".marketType" class="form-control"
								name=".marketType">
									<option value="0">百货</option>
									<option value="1">购物中心</option>
							</select></td>
							<td><input type="text" maxlength="20" value=""
								class="f_5" name=".regionNo" id=".regionNo"></td>
							<td><input type="text" maxlength="20" value=""
								class="f_5" name=".provinceNo" id=".provinceNo"></td>
							<td><input type="text" maxlength="20" value=""
								class="f_5" name=".cityNo" id=".cityNo"></td>
							<td><input type="text" maxlength="20" value=""
								class="f_5" name=".companyNo" id=".companyNo"></td>
							<td><input type="text" maxlength="20" value=""
								class="f_5 " name=".floor" id=".floor"></td>
							<td><input type="text" maxlength="20" value=""
								class="f_5 " name=".cooperateMode" id=".cooperateMode"></td>
							<td><input type="text" maxlength="20" value=""
								class="f_5 " name=".operateArea" id=".operateArea"></td>
							<td><input type="text" maxlength="20" value=""
								class="f_5 " name=".specialPosition" id=".specialPosition"></td>
							<td><input type="text" maxlength="20" value=""
								class="f_5 " name=".sellCondition" id=".sellCondition"></td>
							<td><input type="button"
								onclick="delete_tr(this,'#delScopeId')" value="删除"
								class="btn btn-default btn-sm"></td>
						</tr>
						<!-- 隐藏行，用于新增明细end -->
					</tbody>
				</table>
				<input type="hidden" name="delScopeId" id="delScopeId">
				<div class="f_12">
				     <button type="button" class="btn btn-danger btn_5 btn_right" onclick="history.go(-1)">返&nbsp;回</button>
				     <button type="submit" id="save" class="btn btn-success btn_5 btn_right" >保&nbsp;存</button>
				</div>
		 			</form:form>
                   </div>
              </div>
		  </div>
	</div>	
</div>
</body>
</html>